package com.jackchong.utils;

import android.view.View;

import java.util.List;

/**
 * 作者: jack(黄冲)
 * 邮箱: 907755845@qq.com
 * create on 2018/9/28 10:42
 */

public abstract class CommonAdapter<T> extends MultiItemTypeAdapter<T> {


    public CommonAdapter(final int layoutId, List<T> datas) {
        super(datas);

        addItemViewDelegate(new ItemViewDelegate<T>() {
            @Override
            public int getItemViewLayoutId() {
                return layoutId;
            }

            @Override
            public boolean isForViewType(T item, int position) {
                return true;
            }

            @Override
            public void onCreateView(ViewHolder viewHolder, View convertView, int position) {

            }

            @Override
            public void convert(ViewHolder holder, T t, int position) {
                CommonAdapter.this.convert(holder, t, position);
            }
        });
    }

    protected abstract void convert(ViewHolder viewHolder, T item, int position);
}
